package com.itheima.chapter11.udp.chat;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Scanner;

public class SendMessage {
    public static void main(String[] args) throws IOException {
        DatagramSocket ds= new DatagramSocket();
        Scanner sc =new Scanner(System.in);
        while(true) {
            System.out.println("请输入你要说的话");
            String str = sc.nextLine();
            if ("886".equals(str)) {
                break;
            }
            byte[] bys = str.getBytes();
            DatagramPacket dp = new DatagramPacket(bys, bys.length, InetAddress.getByName("127.0.0.1"), 10086);
            ds.send(dp);
        }
        ds.close();
    }
}
